package com.blueocean_health.care.management.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.blueocean_health.care.management.domain.dto.StaticNurseDto;
import com.blueocean_health.care.management.domain.dto.StaticResourcesDto;
import com.blueocean_health.care.management.mapper.StaticNurseMapper;
import com.blueocean_health.care.management.mapper.StaticResourcesMapper;
import com.blueocean_health.care.management.service.StaticResourceService;

/**
 * 静态资源  2018年3月9日17:52:31
 * @author wuyanli
 *
 */
@Service
public class StaticResourceServiceImpl implements StaticResourceService {
	
	@Resource
	private StaticResourcesMapper resourceDao;
	
	@Resource
	private StaticNurseMapper nurseDao;
	
	//用户端静态图片地址
	@Value("${service.address.userstatic}")
	private String serviceAddress;
    //客服电话 配置
	@Value("${static.kfphone}")
	private String kfphone;
	/**
	 * 根据位置不同获取静态资源信息
	 */
	@Override
	public List<StaticResourcesDto> getStaticResources(Map<String, String> map) {
		//默认静态资源城市码设置为 999
		map.put("staticCity", "999");
		List<StaticResourcesDto> staticResources = resourceDao.getStaticResources(map);
		for (StaticResourcesDto staticResourcesDto : staticResources) {
			//拼接静态资源路径
			staticResourcesDto.setStaticPig(serviceAddress+staticResourcesDto.getStaticPig());
			//三方链接不拼路径
			if(!staticResourcesDto.getStaticUrl().startsWith("http")){
				staticResourcesDto.setStaticUrl(serviceAddress+staticResourcesDto.getStaticUrl());
			}
		}
		return staticResources;
	}

	/**
	 * 查询某城市的静态护工资源 2018年3月12日14:11:42
	 */
	@Override
	public List<StaticNurseDto> getStaticNurse(Map<String, String> map) {
		//默认静态资源城市码设置为 999
		map.put("staticCity", "999");
		List<StaticNurseDto> staticNurse = nurseDao.getStaticNurse(map);
		for (StaticNurseDto staticNurseDto : staticNurse) {
			//拼接静态资源路径
			staticNurseDto.setNursePig(serviceAddress+staticNurseDto.getNursePig());
			//三方链接不拼路径
			if(!staticNurseDto.getNurseUrl().startsWith("http")){
				staticNurseDto.setNurseUrl(serviceAddress+staticNurseDto.getNurseUrl());
			}
		}
		return staticNurse;
	}
	@Override
	public String getkfphone(){
		return kfphone;
		
	}
}
